import { UserType } from 'configs/userPage';

export type UserOwnProfileApi = {
    login: string;
    id: number;
    node_id: string;
    avatar_url: string;
    gravatar_id: string;
    url: string;
    html_url: string;
    followers_url: string;
    following_url: string;
    gists_url: string;
    starred_url: string;
    subscriptions_url: string;
    organizations_url: string;
    repos_url: string;
    events_url: string;
    received_events_url: string;
    type: UserType;
    site_admin: boolean;
    name: string;
    company: string | null;
    blog: string;
    location: string | null;
    email: string | null;
    hireable: string | null;
    bio: string | null;
    twitter_username: string | null;
    public_repos: number;
    public_gists: number;
    followers: number;
    following: number;
    created_at: string;
    updated_at: string;
    private_gists: number;
    total_private_repos: number;
    owned_private_repos: number;
    disk_usage: number;
    collaborators: number;
    two_factor_authentication: boolean;
    plan: {
        name: string;
        space: number;
        collaborators: number;
        private_repos: number;
    };
};

export type UserOwnProfileModel = {
    login: string;
    id: number;
    avatarUrl: string;
    htmlUrl: string;
    type: UserType;
    name: string;
    blog: string;
    location: string | null;
    email: string | null;
    publicRepos: number;
    followers: number;
    following: number;
    createdAt: string;
    updatedAt: string;
};

export const normalizeUserOwnProfile = (from: UserOwnProfileApi): UserOwnProfileModel => ({
    ...from,
    avatarUrl: from.avatar_url,
    htmlUrl: from.html_url,
    publicRepos: from.public_repos,
    createdAt: from.created_at,
    updatedAt: from.updated_at,
});
